(*version)++;
}
-static inline void __update_vcpu_system_time(struct vcpu *v)
+void update_vcpu_system_time(struct vcpu *v)
{
struct cpu_time *t;
struct vcpu_time_info *u;
+ if ( v->vcpu_info == NULL )
+ return;
+
t = &this_cpu(cpu_time);
u = &vcpu_info(v, time);
+ if ( u->tsc_timestamp == t->local_tsc_stamp )
+ return;
+
version_update_begin(&u->version);
u->tsc_timestamp = t->local_tsc_stamp;
version_update_end(&u->version);
}
-void update_vcpu_system_time(struct vcpu *v)
-{
- if ( vcpu_info(v, time.tsc_timestamp) !=
- this_cpu(cpu_time).local_tsc_stamp )
- __update_vcpu_system_time(v);
-}
-
void update_domain_wallclock_time(struct domain *d)
{
spin_lock(&wc_lock);
local_irq_enable();
#if 0
- printk("PRE%d: tsc=%lld stime=%lld master=%lld\n",
+ printk("PRE%d: tsc=%"PRIu64" stime=%"PRIu64" master=%"PRIu64"\n",
smp_processor_id(), prev_tsc, prev_local_stime, prev_master_stime);
- printk("CUR%d: tsc=%lld stime=%lld master=%lld -> %lld\n",
+ printk("CUR%d: tsc=%"PRIu64" stime=%"PRIu64" master=%"PRIu64
+ " -> %"PRId64"\n",
smp_processor_id(), curr_tsc, curr_local_stime, curr_master_stime,
curr_master_stime - curr_local_stime);
#endif
t->stime_local_stamp = curr_local_stime;
t->stime_master_stamp = curr_master_stime;
+ update_vcpu_system_time(current);
+
out:
set_timer(&t->calibration_timer, NOW() + EPOCH);
v->domain = d;
v->vcpu_id = vcpu_id;
- v->vcpu_info = shared_info_addr(d, vcpu_info[vcpu_id]);
spin_lock_init(&v->pause_lock);
v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline;
v->runstate.state_entry_time = NOW();
if ( !is_idle_domain(d) )
+ {
set_bit(_VCPUF_down, &v->vcpu_flags);
+ v->vcpu_info = shared_info_addr(d, vcpu_info[vcpu_id]);
+ }
if ( sched_init_vcpu(v, cpu_id) != 0 )
{
stop_timer(&prev->periodic_timer);
/* Ensure that the domain has an up-to-date time base. */
- if ( !is_idle_vcpu(next) )
- {
- update_vcpu_system_time(next);
- vcpu_periodic_timer_work(next);
- }
+ update_vcpu_system_time(next);
+ vcpu_periodic_timer_work(next);
TRACE_4D(TRC_SCHED_SWITCH,
prev->domain->domain_id, prev->vcpu_id,